<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Cate extends CI_Controller {

	function __construct()
    {
        parent::__construct();
		$this->load->model("Cate_model");
    }
	
	public function index()
	{	
		$data['cates'] = $this->Cate_model->getAll();
		$this->load->view('cate',$data);
	}
	
	public function cateadd()
	{
		
		if(IS_POST)
		{
			$this->Cate_model->add();
			redirect("cate/index");
		}else
		{
			$this->load->view('cateadd');
		}
	}
	
	public function cateedit()
	{
		if(IS_POST)
		{
			$this->Cate_model->edit();
			redirect("cate/index");
		}else
		{
			$data['id'] = $this->uri->segment(4);
			$data['cate'] = $this->Cate_model->getOne($data['id']);
			$this->load->view('cateedit',$data);
		}
		
	}
	
	public function del()
	{
		$this->Cate_model->del();
		redirect("cate/index");
	}
}
